<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div id="diario">    
    <br>
    <table>
        <tr>
            <td>Domingo</td>
            <td>Segunda</td>
            <td>Terça</td>
            <td>Quarta</td>
            <td>Quinta</td>
            <td>Sexta</td>
            <td>Sábado</td>
        </tr>
        <tr>

            <c:forEach var="dia" begin="1" end="7">
                 <c:choose>
                <c:when test="${dia==1}">
                    <c:set var="nomeParam" value="domingo"/>
                </c:when>
                <c:when test="${dia==2}">
                    <c:set var="nomeParam" value="segunda"/>
                </c:when>
                <c:when test="${dia==3}">
                    <c:set var="nomeParam" value="terca"/>
                </c:when>
                <c:when test="${dia==4}">
                    <c:set var="nomeParam" value="quarta"/>
                </c:when>
                <c:when test="${dia==5}">
                    <c:set var="nomeParam" value="quinta"/>
                </c:when>
                <c:when test="${dia==6}">
                    <c:set var="nomeParam" value="sexta"/>
                </c:when>
                <c:when test="${dia==7}">
                    <c:set var="nomeParam" value="sabado"/>
                </c:when>
            </c:choose>
                <sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
                    select horarios.*, dia from horarios
                    left join horarios_turmas on horarios.id_horario=horarios_turmas.id_horario and dia=? and id_turma=?
                    where id_turno=?
                    order by hora_inicio
                    <sql:param value="${dia}"/>
                    <sql:param value="${param.id_turma}"/>
                    <sql:param value="${param.id_turno}"/>
                </sql:query>
                <td>
                    <c:forEach var="row" items="${query.rows}">
                        <input type="checkbox" name="${nomeParam}" value="${row.id_horario}" ${row.dia==dia?'checked':''}/>${row.hora_inicio} - ${row.hora_fim}
                        <br>
                    </c:forEach>
                </td>
            </c:forEach>
        </tr>
    </table>
</div>

